package com.base.caselib.presenter;

import android.app.Activity;
import android.text.TextUtils;

import com.base.caselib.bean.LawStatuteBean;
import com.base.caselib.bean.LawStatuteDetailListBean;
import com.base.caselib.view.LawStatuteListView;
import com.base.commonlib.base.presenter.BasePresenter;
import com.base.commonlib.http.RealNetWorkUtil;
import com.base.commonlib.http.utils.CallBackImpl;

import java.util.List;
import java.util.Map;

import io.reactivex.disposables.Disposable;

/**
 * Created by zw on 2019/10/18.
 * 法律法规请求数据
 */

public class LawStatutePresenter extends BasePresenter<LawStatuteListView> {


    public LawStatutePresenter(LawStatuteListView view, Activity activity) {
        super(view, activity);
    }

    @Override
    public void start() {
        super.start();
    }



    public void getLaw(Map<String,String> map){
        //初始化控件
        mView.showPb_mes("正在加载");
        Disposable disposable = RealNetWorkUtil.postContent()
                .content(map)
                .method("api-process/lProce/getDic")
                .build().enqueueForArray(LawStatuteBean.class, new CallBackImpl<List<LawStatuteBean>>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        if (!TextUtils.isEmpty(msg)) {
                            mView.showMes(msg);
                        }

                    }
                    @Override
                    public void onNext(List<LawStatuteBean> caseDetailBean) {
                        mView.hidePb_mes();
                        mView.returnLawStatuteBean(caseDetailBean);
                    }
                });
        mCompositeDisposable.add(disposable);
    }



    public void getLawItems(Map<String,Object> map){
        //初始化控件
        mView.showPb_mes("正在加载");
        Disposable disposable = RealNetWorkUtil.get()
                .params(map)
                .method("api-safety/legislation/getList")
                .build().enqueueForArray(LawStatuteDetailListBean.class, new CallBackImpl<List<LawStatuteDetailListBean>>() {
                    @Override
                    public void onError(int code, String msg, String errMsg) {
                        mView.hidePb_mes();
                        if (!TextUtils.isEmpty(msg)) {
                            mView.showMes(msg);
                        }

                    }
                    @Override
                    public void onNext(List<LawStatuteDetailListBean> lawStatuteDetailListBeanList) {
                        mView.hidePb_mes();
                        mView.returnLawStatuteItemsBean(lawStatuteDetailListBeanList);
                    }
                });
        mCompositeDisposable.add(disposable);
    }




}
